package com.yycx.module.pay.provider.handler;

import com.yycx.common.base.entity.EntityMap;
import com.yycx.common.mybatis.interceptor.PageInterceptor;
import com.yycx.common.mybatis.model.PageParams;
import com.yycx.common.mybatis.model.ResultBody;
import com.yycx.common.mybatis.query.CriteriaQuery;
import com.yycx.common.security.OpenHelper;
import com.yycx.module.pay.client.entity.PayBalanceLog;
import org.springframework.stereotype.Component;

/**
 * 用户收支明细扩展
 *
 * @author zyf
 */
@Component("userBalanceLogListHandler")
public class UserBalanceLogListHandler implements PageInterceptor<PayBalanceLog> {


    @Override
    public ResultBody validate(CriteriaQuery cq, EntityMap params) {
        return ResultBody.ok();
    }

    @Override
    public void prepare(CriteriaQuery cq, PageParams pageParams, EntityMap params) {
        Long userId = OpenHelper.getUserId();
        cq.select("user.userId", "user.nickName", "user.userName", "user.avatar");
        cq.createJoin("com.yycx.module.user.client.entity.AppUser").setMainField("userId");
        cq.eq(PayBalanceLog.class, "userId", userId);
    }


}
